﻿using System;

using System.Collections.Generic;
using System.Text;

namespace XLT_MobileTest
{
    public class Vocab
    {
        private Form1 __root;

        private bool _uncommited;

        private int _id;
        private int _language_id;
        private int _language_origin_id;
        private int _last_access;

        private float _level_easy;
        private float _level_difficult;

        private string _content;
        private string _translation;

        private Language _language;
        private Language _language_origin;

        public Vocab(Form1 root, int id, int languageId, int languageOriginId, int last_access, float level1, float level2, string content, string translation)
        {
            __root = root;

            _id = id;
            _language_id = languageId;
            _language_origin_id = languageOriginId;
            _language = new Language(root, _language_id);
            _language_origin = new Language(root, _language_origin_id);
            _last_access = last_access;
            _level_easy = level1;
            _level_difficult = level2;
            _content = content;
            _translation = translation;
            _uncommited = false;
        }

        public Vocab(Form1 root, int id)
        {           
            // TODO: get all via net
            _id = id;
            __root = root;
        }

        public void Submit()
        {
            // TODO:    Submit the changes to the server
            if (_uncommited)
            {

                _uncommited = false;
            }
        }

        public int Id { get { return _id; } set { _id = value; } }
        public Language Language { get { return _language; } set { _language = value; } }
        public Language LanguageOrigin { get { return _language_origin; } set { _language_origin = value; } }
        public int LastAccess { get { return _last_access; } set { _last_access = value; _uncommited = true; } }
        public float LevelEasy { get { return _level_easy; } set { _level_easy = value; _uncommited = true; } }
        public float LevelDifficult { get { return _level_difficult; } set { _level_difficult = value; _uncommited = true; } }
        public string Content { get { return _content; } set { _content = value; } }
        public string ContentFiltered { get { return _content; } }  // TODO: filter abhängig von gewählten Optionen im __root
        public string Translation { get { return _translation; } set { _translation = value; } }
        public string TranslationFiltered { get { return _translation; } }  // TODO: filter abhängig von gewählten Optionen im __root
    }
}
